-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Zendesk ticket tags #17603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zendesk ticket tags #17603
Conversation
- Add ticketTags prop definition to Zendesk app - Add tag management methods: setTicketTags, addTicketTags, removeTicketTags - Enhance update-ticket action with tag support: * Add ticketTags and tagAction props * Support set/add/remove tag operations * Update summary and response format - Add dedicated tag management actions: * set-ticket-tags: Replace all existing tags * add-ticket-tags: Append to existing tags * remove-ticket-tags: Remove specific tags - Follow Zendesk Tags API specification - Support custom subdomain for Enterprise accounts
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
WalkthroughZendesk integration is expanded with new actions for managing ticket tags: adding, removing, and setting tags, supported by new methods in the Zendesk app module. The update-ticket action now supports optional tag operations. Freshdesk's update-ticket action is enhanced to optionally add internal notes to tickets. All changes introduce new properties and methods without altering existing control flow. Changes
Sequence Diagram(s)Zendesk Ticket Tag Management (Generalized Flow)sequenceDiagram
participant User
participant ZendeskAction
participant ZendeskApp
participant ZendeskAPI
User->>ZendeskAction: Trigger action (add/set/remove tags)
ZendeskAction->>ZendeskApp: Call tag method (addTicketTags/setTicketTags/removeTicketTags)
ZendeskApp->>ZendeskAPI: Send HTTP request to /tickets/{ticketId}/tags.json
ZendeskAPI-->>ZendeskApp: Return API response
ZendeskApp-->>ZendeskAction: Return result
ZendeskAction-->>User: Export summary and response
Freshdesk Update Ticket with Optional Internal NotesequenceDiagram
participant User
participant UpdateTicketAction
participant FreshdeskAPI
User->>UpdateTicketAction: Trigger update-ticket with internalNote/noteBody
alt internalNote is true and noteBody provided
UpdateTicketAction->>FreshdeskAPI: POST /tickets/{ticketId}/notes (private)
FreshdeskAPI-->>UpdateTicketAction: Return note response
UpdateTicketAction-->>User: Export note summary and response
else
UpdateTicketAction->>FreshdeskAPI: PUT /tickets/{ticketId}
FreshdeskAPI-->>UpdateTicketAction: Return update response
UpdateTicketAction-->>User: Export update summary and response
end
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/freshdesk/actions/update-ticket/update-ticket.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/zendesk/actions/add-ticket-tags/add-ticket-tags.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@seynadio is attempting to deploy a commit to the Pipedreamers Team on Vercel. A member of the Team first needs to authorize it. |
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (2)
components/zendesk/actions/update-ticket/update-ticket.mjs (2)
134-142
: Remove redundant case clause.The explicit
case "set":
is redundant since thedefault:
clause performs the same action.Apply this diff to remove the useless case:
- case "set": - default: - tagResponse = await this.app.setTicketTags({ - step, - ticketId, - tags: ticketTags, - customSubdomain, - }); - break; + default: + tagResponse = await this.app.setTicketTags({ + step, + ticketId, + tags: ticketTags, + customSubdomain, + }); + break;
149-154
: Consider consistent return value structure.When tags are handled, the action returns
{ ticket: response, tags: tagResponse }
, but when no tags are provided, it returnsresponse
directly. This inconsistency could complicate usage for consumers who need to handle both cases.Consider always returning a consistent structure:
- return { - ticket: response, - tags: tagResponse, - }; + return { + ticket: response, + tags: tagResponse, + }; } - step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`); - return response; + step.export("$summary", `Successfully updated ticket with ID ${response.ticket.id}`); + return { + ticket: response, + tags: null, + };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
components/freshdesk/actions/update-ticket/update-ticket.mjs
(3 hunks)components/zendesk/actions/add-ticket-tags/add-ticket-tags.mjs
(1 hunks)components/zendesk/actions/remove-ticket-tags/remove-ticket-tags.mjs
(1 hunks)components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs
(1 hunks)components/zendesk/actions/update-ticket/update-ticket.mjs
(4 hunks)components/zendesk/zendesk.app.mjs
(2 hunks)
🧰 Additional context used
🧠 Learnings (2)
components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs (1)
Learnt from: jcortes
PR: PipedreamHQ/pipedream#14467
File: components/gainsight_px/actions/create-account/create-account.mjs:4-6
Timestamp: 2024-10-30T15:24:39.294Z
Learning: In `components/gainsight_px/actions/create-account/create-account.mjs`, the action name should be "Create Account" instead of "Create Memory".
components/zendesk/actions/update-ticket/update-ticket.mjs (2)
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-07-04T18:11:59.822Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
Learnt from: GTFalcao
PR: PipedreamHQ/pipedream#12731
File: components/hackerone/actions/get-members/get-members.mjs:3-28
Timestamp: 2024-10-08T15:33:38.240Z
Learning: When exporting a summary message in the `run` method of an action, ensure the message is correctly formatted. For example, in the `hackerone-get-members` action, the correct format is `Successfully retrieved ${response.data.length} members`.
🪛 Biome (1.9.4)
components/zendesk/actions/update-ticket/update-ticket.mjs
[error] 134-134: Useless case clause.
because the default clause is present:
Unsafe fix: Remove the useless case.
(lint/complexity/noUselessSwitchCase)
🔇 Additional comments (11)
components/freshdesk/actions/update-ticket/update-ticket.mjs (1)
111-114
: Fix destructuring to exclude internal note properties from ticket update data.The current destructuring includes
internalNote
andnoteBody
in the spread operator, which means these properties will be included in thedata
object passed to the ticket update API. These are not valid ticket fields and should be excluded.const { freshdesk, ticketId, internalNote, noteBody, - ...fields + ...ticketFields } = this; -const data = removeNullEntries(fields); +// Exclude internal note properties from ticket update data +const { internalNote: _, noteBody: __, ...fields } = ticketFields; +const data = removeNullEntries(fields);Likely an incorrect or invalid review comment.
components/zendesk/zendesk.app.mjs (2)
177-182
: LGTM: Well-defined ticketTags property.The property definition is clear and follows existing patterns in the codebase.
309-371
: LGTM: Excellent implementation of tag management methods.The three new methods are well-implemented with:
- Appropriate HTTP methods (PUT for set, POST for add, DELETE for remove)
- Consistent method signatures and parameter handling
- Comprehensive JSDoc documentation
- Proper integration with existing
makeRequest
methodcomponents/zendesk/actions/add-ticket-tags/add-ticket-tags.mjs (1)
1-48
: LGTM: Clean and consistent implementation.The action follows established patterns with:
- Proper use of propDefinitions from the app
- Clear and descriptive metadata
- Appropriate method call to the app's
addTicketTags
method- Informative summary message
components/zendesk/actions/remove-ticket-tags/remove-ticket-tags.mjs (1)
1-48
: LGTM: Consistent and well-structured implementation.The action follows established patterns with:
- Proper use of propDefinitions from the app
- Clear documentation referencing Zendesk API docs
- Appropriate method call to the app's
removeTicketTags
method- Informative summary message
components/zendesk/actions/set-ticket-tags/set-ticket-tags.mjs (1)
1-47
: LGTM: Well-implemented tag replacement action.The action follows established patterns with:
- Proper use of propDefinitions from the app
- Clear documentation emphasizing the replacement behavior
- Appropriate method call to the app's
setTicketTags
method- Informative summary message
components/zendesk/actions/update-ticket/update-ticket.mjs (5)
6-6
: LGTM!The description update accurately reflects the new tag management functionality.
8-8
: LGTM!Version increment is appropriate for the added functionality.
47-73
: LGTM!The new prop definitions are well-structured with clear descriptions and appropriate options for tag management.
146-147
: LGTM!The summary formatting follows the correct pattern and provides clear information about the operations performed.
113-143
: Tag methods verified in Zendesk app module
All three methods—setTicketTags
(line 317),addTicketTags
(line 338), andremoveTicketTags
(line 359)—are implemented incomponents/zendesk/zendesk.app.mjs
. No further action is required.
if (!Object.keys(data).length) { | ||
throw new Error("Please provide at least one field to update."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Adjust validation logic to handle internal note scenarios.
The current validation will fail if a user only provides internal note fields since they're excluded from the data
object, even though the action can still perform the internal note operation.
-if (!Object.keys(data).length) {
+if (!Object.keys(data).length && !(internalNote && noteBody)) {
throw new Error("Please provide at least one field to update.");
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (!Object.keys(data).length) { | |
throw new Error("Please provide at least one field to update."); | |
} | |
if (!Object.keys(data).length && !(internalNote && noteBody)) { | |
throw new Error("Please provide at least one field to update."); | |
} |
🤖 Prompt for AI Agents
In components/freshdesk/actions/update-ticket/update-ticket.mjs around lines 135
to 137, the validation logic incorrectly throws an error when only internal note
fields are provided because these fields are excluded from the data object.
Modify the validation to also check if internal note fields are present and
allow the operation to proceed if either data fields or internal note fields
exist, ensuring internal note updates are not blocked.
if (internalNote && noteBody) { | ||
const response = await freshdesk._makeRequest({ | ||
$, | ||
method: "POST", | ||
url: `/tickets/${ticketId}/notes`, | ||
data: { | ||
body: noteBody, | ||
private: true, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`); | ||
return response; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider supporting both internal note and ticket update in a single action call.
The current implementation creates an either/or scenario - users can either add an internal note OR update ticket fields, but not both. This limits the action's flexibility and may not align with user expectations.
Consider refactoring to support both operations:
if (internalNote && noteBody) {
- const response = await freshdesk._makeRequest({
+ const noteResponse = await freshdesk._makeRequest({
$,
method: "POST",
url: `/tickets/${ticketId}/notes`,
data: {
body: noteBody,
private: true,
},
});
-
- $.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`);
- return response;
}
Then update the summary logic to reflect both operations when performed.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if (internalNote && noteBody) { | |
const response = await freshdesk._makeRequest({ | |
$, | |
method: "POST", | |
url: `/tickets/${ticketId}/notes`, | |
data: { | |
body: noteBody, | |
private: true, | |
}, | |
}); | |
$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`); | |
return response; | |
} | |
if (internalNote && noteBody) { | |
const noteResponse = await freshdesk._makeRequest({ | |
$, | |
method: "POST", | |
url: `/tickets/${ticketId}/notes`, | |
data: { | |
body: noteBody, | |
private: true, | |
}, | |
}); | |
} |
🤖 Prompt for AI Agents
In components/freshdesk/actions/update-ticket/update-ticket.mjs around lines 120
to 133, the current code only supports adding an internal note or updating
ticket fields exclusively. Refactor the code to allow both adding an internal
note and updating ticket fields within the same action call by performing both
API requests if their respective data is present. Then, update the summary
export to reflect both operations when they occur together, ensuring the action
is more flexible and meets user expectations.
Closing this PR and replacing with #17609 which has only the Zendesk changes (no accidental Freshdesk changes) and represents a comprehensive ticket tag management implementation |
WHY
Summary by CodeRabbit
New Features
Improvements